//
//  DetailZBViewController.m
//  JRTTDemo
//
//  Created by 赵 on 2018/2/9.
//  Copyright © 2018年 袁书辉. All rights reserved.
//

#import "DetailZBViewController.h"

@interface DetailZBViewController ()<ZFPlayerDelegate>

@end

@implementation DetailZBViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [PPNetworkHelper GET:@"https://is.snssdk.com/live_talk/info/?resolution=640*1136&ab_feature=z2,201616&vid=921681CE-A23A-4041-81E7-BFB55084F330&app_name=news_article&channel=App%20Store&openudid=224a615d8075937766a9e52ccdb657015169ac08&device_type=iPhone%205%20(Global)&ssmix=a&aid=13&idfv=921681CE-A23A-4041-81E7-BFB55084F330&os_version=10.3.3&device_platform=iphone&ab_client=a1,f2,f7,e1&ab_group=z2,201616&ac=WIFI&version_code=6.4.8&idfa=39DD7AC7-3269-4CDD-9875-BD0D2D68BD28&ab_version=263093,276220,275651,271178,272853,252768,249828,246859,275641,249684,249687,264840,268795,249667,274584,206077,249673,229305,249672,271842,276638,277466,276808,271717,277007,270387,185733,202918,251714,254103,277523,31648,276018,270333,276297,274557,270106,258356,247847,276163,277106,264449,249045,271662,270163,244746,273960,274293,264614,260649,241836,210247,241181,276503,268342,232362,265707,271193,273231,239096,271117,272014,170988,269426,273499,219181,276204,277310,257280,261294,209482&iid=20850169927&device_id=43956360441" parameters:@{
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            @"live_id":self.live_id
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            } success:^(id responseObject) {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                // 初始化控制层view(可自定义)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                ZFPlayerControlView *controlView = [[ZFPlayerControlView alloc] init];
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                // 初始化播放模型
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                ZFPlayerModel *playerModel = [[ZFPlayerModel alloc] init];
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                // playerView的父视图
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                playerModel.fatherView = self.playerView.superview;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                NSString * playUrl =      responseObject[@"data"][@"background"][@"video"][@"play_back_url"];                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   playerModel.videoURL =[NSURL URLWithString:playUrl];
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                playerModel.title = responseObject[@"data"][@"title"];
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                [self.playerView playerControlView:controlView playerModel:playerModel];
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                // 设置代理
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                self.playerView.delegate = self;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                // 自动播放
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                [self.playerView autoPlayTheVideo];
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
        
    } failure:^(NSError *error) {
        
    }];
    
    
    
    
}
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    
    [self.navigationController setNavigationBarHidden:YES animated:animated];
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    
    [self.navigationController setNavigationBarHidden:NO animated:animated];
}

/** 返回按钮事件 */
- (void)zf_playerBackAction
{
    [self.navigationController popViewControllerAnimated:YES];
}
/** 下载视频 */
- (void)zf_playerDownload:(NSString *)url
{
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
